class Task52:
    def run(self, head1, head2):
        list1_length = self.get_list_length(head1)
        list2_length = self.get_list_length(head2)

        if list1_length > list2_length:
            for _ in range(list1_length - list2_length):
                head1 = head1.next
        elif list1_length < list2_length:
            for _ in range(list2_length - list1_length):
                head2 = head2.next

        while head1 is not None and head2 is not None:
            if head1 is head2:
                return head1
            else:
                head1 = head1.next
                head2 = head2.next
        return None

    def get_list_length(self, head):
        node = head
        length = 0
        while node is not None:
            node = node.next
            length += 1
        return length
